//计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
public class SumFractions {

        public static void main (String[]args){
            double sum;
            double sum1 = 0.0;
            double sum2 = 0.0;
            for (int i = 1; i < 100; i += 4) {
                double ret1 = 1.0 / i + 1.0 / (i + 2);
                sum1 += ret1;
            }
            for (int j = 2; j <= 100; j += 4) {
                double ret2 = 1.0 / j + 1.0 / (j + 2);
                sum2 += ret2;
            }
            sum = sum1 - sum2;
            System.out.println("sum1 = " + sum1);
            System.out.println("sum2 = " + sum2);
            System.out.println("sum = " + sum);
        }
    }
}